import scopt.test.common
from scopt.mpu.business.devel.handlers import echo


class RegistryTest(scopt.test.common.ScoptTest):
    def test_echo(self):
        request = self.request(echo.echo)
        request['reqd'] = {'text': 'text 1'}
        response = self.send_request(request)
        response_status = response['resh']['status']
        response_text = response['resd']['text']
        response_note = response['resh']['note']
        self.assertEqual(response_status, 'OK')
        self.assertEqual(response_text, '0.1: text 1')
        self.assertTrue(len(response_note) > 0)

    def test_echo_2(self):
        request = self.request(echo.echo2)
        request['reqh']['version'] = '0.2'
        request['reqd'] = {'text': 'text 2'}
        response = self.send_request(request)
        response_status = response['resh']['status']
        response_text = response['resd']['text']
        response_note = response['resh']['note']
        self.assertEqual(response_status, 'OK')
        self.assertEqual(response_text, '0.2: text 2')
        self.assertTrue(len(response_note) == 0)
